<template>
  <div>

    <el-card class="box-card">
      <el-row :gutter="10">
        <el-col :span="16">
          <el-col :span="6">
            <el-select v-model="aId" placeholder="请选择状态">
              <el-option
                  v-for="item in activityList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
              ></el-option>
            </el-select>
          </el-col>

          <el-button @click="paging(1)" type="primary" round icon="el-icon-search">查询</el-button>
          <el-button type="info" @click="clear">重置</el-button>
        </el-col>


      </el-row>

    </el-card>
    <el-table
        :data="page.list"
        style="width: 100%;margin-top: 20px;">
      <el-table-column
          prop="id"
          label="ID">
      </el-table-column>
      <el-table-column
          prop="user.username"
          label="用户名称">
      </el-table-column>
      <el-table-column
          prop="activity.name"
          label="活动名称">
      </el-table-column>
      <el-table-column
          prop="text"
          label="花絮">
      </el-table-column>
      <el-table-column
          prop="state"
          label="状态"
      >
        <template slot-scope="scope">
          <el-tag type="danger" v-if="scope.row.state==0">未发放学分</el-tag>
          <el-tag type="success" v-if="scope.row.state==1">已发放学分</el-tag>
        </template>
      </el-table-column>


      <el-table-column
          fixed="right"
          header-align="center"
          align="center"
          label="操作">
        <template slot-scope="scope">
          <el-link circle type="success" icon="el-icon-edit" v-if="scope.row.state==0" @click="check(scope.row.id)">审核通过</el-link>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
        @size-change="handleSizeChange"
        @current-change="paging"
        :current-page="page.Num"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="100"
        layout="total, sizes, prev, pager, next, jumper"
        :total="page.total">
    </el-pagination>

  </div>
</template>

<script>
export default {
  name: "CrowdView",
  data(){
    return{
      aId:"",
      page:{},
      pageSize:5,
      activityList:[],





    }

  },
  methods:{
    check(id){
      this.$axios.post('/activityFlower/check?id='+id).then(resp=>{
        if (resp.data.code){
          this.$message.success("发放成功")
        }else{
          this.$message.error("发放失败")
        }
      })


    },

    getActivity(){
      this.$axios.post('/activity/list').then(resp=>{
        this.activityList=resp.data.list
      })
    },





    clear(){
      this.aId=''

      this.paging(1)
    },

    paging(curPage){
      this.$axios.get("activityFlower/list?curPage="+curPage+"&pageSize="+this.pageSize+ "&aid="+this.aId).then(resp=>{
        this.page=resp.data
        console.log("this.page",this.page)
      })
    },
    handleSizeChange(pageSize){
      this.pageSize=pageSize
      this.paging(1)
    },
    reset(){


    },

    refreshPage() {
      // 执行完操作后调用location.reload()方法刷新页面
      location.reload();
    },





  },
  created() {
    this.getActivity()
    this.paging(1)


  }
}
</script>

<style scoped>

</style>
